<?php
class Helpers_SiteCellar extends Zend_View_Helper_Abstract { 
	
	function siteCellar($name) {
		
		$cache = new Cache_Slot_Array('footer_main_site');
		$groupitems = $cache->load();
		if (empty($groupitems)) {
			$fgroups = SectionPagePeer::getInstance()->fetchAll();
			$groupitems = array();
			
			foreach($fgroups as $group => $val){
				$section_id = $val->id;
				$items = PagesService::getInstance()->getSubMenu($section_id);
				$fpage = array();
				foreach($items as $item){
					$url = $item->url != '' ? $item->url : '/pages/'.$item->key.'/';
					$fpage[] = array(
						'url' => $url,
						'title' => $item->title,
						'enable' => $item->is_pub,
						'show' => $item->in_nav,
						'in_map' => $item->static_in_map
					);
				}
				$groupitems[$group] = array(
					'fpage' => $fpage,
					'groupname' => $val->name,
					'parent_show' => $val->show_menu,
					'in_map_show' => $val->in_map
				);
			}
			$cache->save($groupitems);
		}
		$this->view->footer = $groupitems;
		
		echo $this->view->render($name);
	}
}